#!/bin/sh

if [ -d ../branches/$1 ]
then
	echo "Updating translations for $1..."
	cd ../branches/$1
	for pot in ../$1-POT/*.pot ; do
		po=`basename $pot .pot`.po
		
		if [ -f $po ]
		then
			echo "Updating $po: \c"
			msgmerge --no-wrap -o $po $po $pot ;
		else
			echo "Creating new file $po: \c"
			msgmerge --no-wrap -o $po /dev/null $pot ;
		fi
	done
	echo "All $1 files have been updated." ;
else
	echo "The branch '$1' does not exist. A valid branch must be specified."
	echo "Usage: ./update-from-pot.sh [BRANCH]."
fi